<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="author" content="zhangcheng">
	<title>有卡注销</title>
	<script language="javascript" type="text/javascript" src="../script/print.js"></script>
	<script language="javascript" src="../script/common.js" type="text/javascript"></script>
	<script language="javascript" src="../script/card.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">
	var cardPin;
	//页面控件初始化
	function load(){
		Eui.showNavigation();//导航
		
		setPages(["readcardview","detview"]);
		CardMgnt.cardUser.show("userinfo",null,CardMgnt.PERSONALVIEW)
	}
	//读卡方法，卡片必须是流通状态的卡片
	function onReadCard(){
		try{
			getCard();
			var data = DWR.syncCall("mgntQueryService.checkRevWithCard",getAsn())
			var card = data.card;
			var cardType = data.cardType;
			var cardUser = data.cardUser;
			
			if (!CardMgnt.checkRevocate(card,cardType,Constants.PERSONAL)) return;
			
			var c = getCardDetail({disBalance:true,disLoyalty:true,grayStatus:true,tradeDate:data.serverTime})
			if (c.grayFund || c.grayPoint){
				showWarning("灰锁状态的卡片不能执行此操作。");return;
			}
			cardPin = c.cardPin;
			
			var cardObj = CardMgnt.convertCardObject(data,c);
			cardObj.spareBalance = Format.fenToYuan(data.balanceMap?data.balanceMap.balance:0);
			cardObj.spareLoyaltyBalance = Format.fenToYuan(data.balanceMap?data.balanceMap.loyaltyBalance:0);
			
			Common.setValues(readCardForm,cardObj);
			CardMgnt.cardUser.showData("userinfo",data,CardMgnt.PERSONALVIEW)
			
			$("revocationbtn").disabled = false;
			
			readCardForm.foregiftAmount.value = Format.fenToYuan(card.foregiftAmount);
			readCardForm.feeAmount.value = Format.fenToYuan(CardMgnt.getFee(Constants.ACCOUNT_FEE_REVOCATE_CARD,card.type));
		}catch(e){showError(e.description);return;}
	}
	
	//销户圈提方法
	function revCardUnload(){
		if(!showQuestion("是否圈提所有卡内资金、积分，做个人销户？")) return;
		var asn = readCardForm.asn.value;
		var amount = readCardForm.cardBalance.value;
		var pointAmount = readCardForm.cardLoyaltyBalance.value;
		try{
			CardMgnt.cardUnload(asn,Format.yuanToFen(amount),Format.yuanToFen(pointAmount),cardPin)
		}catch(e){showError(e.description);return;}
		DWR.call("cardMgntService.cardRevocation",asn,function(data){
			showInformation("销户成功！");
			switchPage("detview");
			CardMgnt.showPrintView("detview","kill_with_card_bill",data.logId,"有卡注销凭证");
			try{
				WebPrint.print("billview");
			}catch(e){
				showError("打印单据出错:"+e.description)
			}
		},{blockScreen:true});
	}
	
	//重置方法
	function onCancel(){
		switchPage("readcardview");
		cardPin = null;
		readCardForm.reset();
		CardMgnt.cardUser.show("userinfo",null,CardMgnt.PERSONALVIEW)
		$("revocationbtn").disabled = true;
	}
	</script>
</head>
<body onload="load()" onunload="releaseCard()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="readcardview">
		<div id="readcarddiv">
			<form name="readCardForm" id="readCardForm">
				<div class="form">
					<div class="formTitle">卡片信息</div>
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="label6">
						<tr>
							<td><label>卡&nbsp;&nbsp;&nbsp;&nbsp;号</label> <input type="text" name="asn" readonly class="readonly"></td>
							<td><label>卡子类型</label> <input type="text" name="subCardTypeText" readonly class="readonly"></td>
						</tr>	
						<tr>
							<td><label>卡片状态</label> <input type="text" name="statusText" readonly class="readonly"></td>
							<td><label>黑名单类型</label> <input type="text" name="blackTypeText" readonly class="readonly"></td>
						</tr>
						<tr>
							<td><label>备用金余额</label> <input type="text" name="spareBalance" readonly class="readonly"> 元</td>
							<td><label>备用积分</label> <input type="text" name="spareLoyaltyBalance" readonly class="readonly"> 分</td>							
						</tr>	
						<tr>
							<td><label>卡 余 额</label> <input type="text" name="cardBalance" readonly class="readonly"> 元</td>
							<td><label>卡内积分</label> <input type="text" name="cardLoyaltyBalance" readonly class="readonly"> 分</td>							
						</tr>
						<tr>
							<td><label>押 金</label> <input type="text" name="foregiftAmount" readonly class="readonly"> 元</td>
							<td><label>手续费</label> <input type="text" name="feeAmount" readonly class="readonly"> 元</td>
						</tr>	
					</table>
				</div>
			</form>
		</div>
		<div id="userinfo"></div>
		<p>
			<button onclick="onReadCard()">读 卡</button>
			<button onclick="revCardUnload()" id="revocationbtn" disabled>销 户</button>
			<button onclick="onCancel()">重 置</button>
		</p>
	</div>
	<div id="detview" style="display:none;">
	</div>
</body>
</html>
